home *** CD-ROM | disk | FTP | other *** search
- Path: hubcap.clemson.edu!hubcap!mjs
- From: mjs@hubcap.clemson.edu (M. J. Saltzman)
- Newsgroups: comp.lang.c
- Subject: Re: Help:what is wrong this code?
- Date: 10 Apr 96 14:37:10 GMT
- Organization: Clemson University
- Message-ID: <mjs.829147030@hubcap>
- References: <4k3p3q$n76@brahms.udel.edu> <4k4hi3$5hm@sparcserver.lrz-muenchen.de> <Pine.ULT.3.92.960409210416.383A-100000@henson.cc.wwu.edu>
- NNTP-Posting-Host: hubcap.clemson.edu
- X-Newsreader: NN version 6.5.0 #1
-
- Norma Mathews <n9341884@henson.cc.wwu.edu> writes:
-
- >On 6 Apr 1996, Kurt Watzka wrote:
-
- >> yuehong@brahms.udel.edu (Yue-hong Zheng) writes:
- >>
- >> >Why it give me 0.0000?
- >>
- >> >#include <stdio.h>
- >> >main () {
- >> >double a=9.008;
- >> >printf("%f\n",sqrt(a));
- >> >return 0;
- >> >}
-
- >your printf specifer needs to be "%lf", not "%f", since a is a double
-
- If you RTFM, you will find that "%f" *is* the printf() format
- specifier for a double. The *scanf()* format specifer for a double is
- "%lf". There is *no* "%lf" specifier for printf() in ANSI C.
-
- I bet his problem is failure to #include <math.h>.
-
-
- --
- Matthew Saltzman
- Clemson University Math Sciences
- mjs@clemson.edu
- --
- Matthew Saltzman
- Clemson University Math Sciences
- mjs@clemson.edu
-